<include file="public@header" />
<style type="text/css">
    .pic-list li {
        margin-bottom: 5px;
    }
</style>
<script type="text/html" id="photos-item-tpl">
    <li id="saved-image{id}">
        <input id="photo-{id}" type="hidden" name="photo_urls[]" value="{filepath}">
        <input class="form-control" id="photo-{id}-name" type="text" name="photo_names[]" value="{name}"
               style="width: 200px;" title="图片名称">
        <img id="photo-{id}-preview" src="{url}" style="height:36px;width: 36px;"
             onclick="imagePreviewDialog(this.src);">
        <a href="javascript:uploadOneImage('图片上传','#photo-{id}');">替换</a>
        <a href="javascript:(function(){$('#saved-image{id}').remove();})();">移除</a>
    </li>
</script>
</head>
<body>
<div class="wrap js-check-wrap">
	<ul class="nav nav-tabs">
		<li><a href="{:url('Goods/index')}">类别列表</a></li>
		<li class="active"><a href="{:url('Goods/add')}">新增类别</a></li>
	</ul>
    <form class="form-horizontal js-ajax-form margin-top-20" role="form" action="{:url('Goods/editPost')}" method="post">
        <fieldset>
            <div class="tabbable">
                <div class="tab-content">
                    <div class="tab-pane active" id="A">
                        <input type="text"  name="g_id" value="{$data.g_id}" style="display:none;">
                        <div class="form-group">
                            <label for="input-site-g_goodsname" class="col-sm-2 control-label"><span class="form-required">*</span>品相名称</label>
                            <div class="col-md-6 col-sm-10">
                                <span class="input-group-addon" id="check_name_btn" style="cursor:pointer;" >验证名称</span>
                                <input type="text" class="form-control" id="input-site-g_goodsname" name="options[g_goodsname]" value="{$data.g_goodsname}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="input-site-g_code" class="col-sm-2 control-label"><span class="form-required">*</span>拼音简码</label>
                            <div class="col-md-6 col-sm-10">
                                <input type="text" class="form-control" id="input-site-g_code" name="options[g_code]" value="{$data.g_code}">
                            </div>
                        </div>                       
                        <div class="form-group">
                            <label for="input-site-g_pic" class="col-sm-2 control-label"><span class="form-required">*</span>品相图片</label>
                            <div class="info_content" id="Personal">
                            <div class="col-md-6 col-sm-10">				                   
					            <tr>                   
		                       		<td>
			                            <ul id="photos" class="pic-list list-unstyled form-inline">
			                                <notempty name="$data.g_pic">
			                                        <php>$img_url=cmf_get_image_preview_url($data['g_pic']);</php>
			                                        <li id="saved-image">
			                                            <img id="photo-0-preview"
			                                                 src="{:cmf_get_image_preview_url($data['g_pic'])}"
			                                                 style="height:36px;width: 36px;"
			                                                 onclick="parent.imagePreviewDialog(this.src);">
			                                           <!--  <a href="javascript:uploadOneImage('图片上传','#photo');">替换</a> -->
			                                            <a href="javascript:(function(){$('#saved-image').remove();})();">移除</a>
			                                        </li>
			                                </notempty>
			                            </ul>
		                            	<a href="javascript:uploadMultiImage('图片上传','#photos','photos-item-tpl');"
		                               class="btn btn-sm btn-default">选择图片</a>
			                        </td>
		                      </tr>
					      </div>
	                      </div>
                        </div>
                        <div class="form-group">
                            <label for="input-site-g_unit" class="col-sm-2 control-label"><span class="form-required">*</span>单位</label>
                            <div class="col-md-6 col-sm-10">
                                <select name="g_unit">
                                    <foreach name="unit" item="vo">
                                    <option value="{$vo.id}" <if condition="$vo['id'] eq $data['g_unit']"> selected</if>>{$vo.name}</option>
                                    </foreach>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="input-site-g_category" class="col-sm-2 control-label"><span class="form-required">*</span>类别</label>
                            <div class="col-md-6 col-sm-10">
                                <select name="g_category">
                                    <foreach name="classify" item="v">
                                    <option value="{$v.id}" <if condition="$v['id'] eq $data['g_category']"> selected</if> >{$v.classify_name}</option>
                                    </foreach>
                                </select>
                            </div>
                        </div>                              
                        <!-- <div class="form-group">
                            <label for="input-site-name" class="col-sm-2 control-label"><span class="form-required">*</span>属性</label>
                            <div class="col-md-6 col-sm-10">
                                <input type="checkbox" name="g_meal" checked="checked" value="1" />套餐
                                <input type="checkbox" name="g_agio" value="1" />折扣
                                <input type="checkbox" name="g_nowprice" value="1" />时价
                                <input type="checkbox" name="buy_get" value="1" />买一送一 
                                <input type="checkbox" name="even" value="1" />偶数半价 
                                <input type="checkbox" name="special_offer" value="1" />特价 
                            </div>
                        </div> -->
                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                                <button type="submit" class="btn btn-primary js-ajax-submit" data-refresh="1">{:lang('SAVE')}</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </fieldset>
    </form>
    <script type="text/javascript">
        $('#check_encrypt_btn').click(function(){
            var encrypt=$("#input-site-g_encrypt").val();//编码
            if(encrypt){
                $.getJSON("{:url('Api/Ajax/check_code_js')}",{encrypt:encrypt},function(data){
                    alert(data.msg);
                });
            }else{
                alert('请输入用户编号');
            }
        });
        $('#check_name_btn').click(function(){
            var name=$("#input-site-g_goodsname").val();//编码
            if(name){
                $.getJSON("{:url('Api/Ajax/check_name_js')}",{name:name},function(data){
                    alert(data.msg);
                });
            }else{
                alert('请输入用户编号');
            }
        });
    </script>
    <!-- 预览js -->  
</div>
<script type="text/javascript" src="__STATIC__/js/admin.js"></script>
</body>
</html>